﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/Default.Master" AutoEventWireup="true" CodeBehind="View.aspx.cs" EnableEventValidation="false" Inherits="Mindscape.BackgroundMotion.Website.View" Title="View" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

<asp:Content ContentPlaceHolderID="BodyContent" runat="server">  

  <asp:PlaceHolder runat="server" ID="StreamingSilverlightScripts" Visible="false">
    <script src="http://agorigin.net/g/silverlight.js" type="text/javascript"></script>
  </asp:PlaceHolder>
  <asp:PlaceHolder runat="server" ID="SilverlightScripts" Visible="false">
    <script src="/Scripts/silverlight.js" type="text/javascript"></script>
    <script src="/Scripts/videoskin.js" type="text/javascript"></script>
    <script src="/Scripts/player.js" type="text/javascript"></script>
  </asp:PlaceHolder>
  
  <mindscape:WebDataBinder runat="server" ID="DataBinder">
    <BindingItems>
      <mindscape:WebDataBindingItem runat="server" BindingMode="OneWay" BindingSource="this"
        BindingSourceMember="Preview" TargetControl="previewImage"/>
      
      <mindscape:WebDataBindingItem runat="server" BindingMode="OneWay" BindingSource="Contribution"
        BindingSourceMember="Description" TargetControl="descriptionLabel" TargetControlProperty="Text"/>
      
      <mindscape:WebDataBindingItem runat="server" BindingMode="OneWay" BindingSource="Contribution"
        BindingSourceMember="Title" TargetControl="titleLabel" TargetControlProperty="Text"/>
        
      <mindscape:WebDataBindingItem runat="server" BindingMode="OneWay" BindingSource="Contribution"
        BindingSourceMember="DownloadLink" TargetControl="downloadLink" TargetControlProperty="NavigateUrl"/>
      
      <mindscape:WebDataBindingItem runat="server" BindingMode="OneWay" BindingSource="Contribution"
        BindingSourceMember="Downloads" TargetControl="downloadedLabel" TargetControlProperty="Text"/>
      
      <mindscape:WebDataBindingItem runat="server" BindingMode="OneWay" BindingSource="Contribution"
        BindingSourceMember="Views" TargetControl="viewedLabel" TargetControlProperty="Text"/>
      
      <mindscape:WebDataBindingItem runat="server" BindingMode="OneWay" BindingSource="Contribution.Contributor"
        BindingSourceMember="Username" TargetControl="ownerLink" TargetControlProperty="Text"/>
        
      <mindscape:WebDataBindingItem runat="server" BindingMode="OneWay" BindingSource="Contribution.Contributor"
        BindingSourceMember="Id" DisplayFormat="~/Member.aspx?u={0}" TargetControl="ownerLink" TargetControlProperty="NavigateUrl"/>
      
      <mindscape:WebDataBindingItem runat="server" BindingMode="OneWay" BindingSource="Contribution"
        BindingSourceMember="AddedOn" TargetControl="addedLabel" TargetControlProperty="Text"/>
      
      <mindscape:WebDataBindingItem runat="server" BindingMode="OneWay" BindingSource="Contribution"
        BindingSourceMember="Comments" TargetControl="commentRepeater" TargetControlProperty="DataSource"/>
      
      <mindscape:WebDataBindingItem runat="server" BindingMode="OneWay" BindingSource="Contribution"
        BindingSourceMember="VirtualEarthLink" TargetControl="VirtualEarthLink" TargetControlProperty="NavigateUrl"/>
      
      <mindscape:WebDataBindingItem runat="server" BindingMode="OneWay" BindingSource="Contribution"
        BindingSourceMember="DownloadExperienceRating" TargetControl="this" TargetControlProperty="ContributionDownloadRating"/>
      
      <mindscape:WebDataBindingItem runat="server" BindingMode="OneWay" BindingSource="Contribution"
        BindingSourceMember="Rating" TargetControl="this" TargetControlProperty="ContributionRating"/>
      
      <mindscape:WebDataBindingItem runat="Server" BindingMode="OneWay" BindingSource="Contribution"
        BindingSourceMember="CanRenderMap" TargetControl="VirtualEarthIntegration" TargetControlProperty="Visible"/>
      
      <mindscape:WebDataBindingItem runat="server" BindingMode="OneWay" BindingSource="Contribution"
        BindingSourceMember="Comments" TargetControl="CommentsRepeater" TargetControlProperty="DataSource"/>
        
      <mindscape:WebDataBindingItem runat="server" BindingMode="OneWay" BindingSource="this"
        BindingSourceMember="HasComments" TargetControl="CommentsRepeater" TargetControlProperty="Visible" />

    </BindingItems>
  </mindscape:WebDataBinder>

	<div>
	  <h1><asp:Literal runat="server" ID="titleLabel"/></h1>
	</div>
  
    <div>
	  <h3><asp:Literal runat="server" ID="descriptionLabel"/></h3>
	</div>
    
		<asp:Literal runat="server" ID="previewImage" />		
 
 <h3>Details</h3>
	
	<div>
      <strong>Added on: </strong><asp:Literal runat="Server" ID="addedLabel" />
	</div>
	<div>
	  <strong>Added by: </strong><asp:HyperLink runat="Server" ID="ownerLink" />	
	</div>
	<div>
	    <strong>Viewed: </strong><asp:Literal runat="Server" ID="viewedLabel" /> times.
	</div>	
	
	<div>
    <asp:HyperLink runat="Server" ID="downloadLink" Text="Download this Item" ImageUrl="~/images/vid-down.gif" style="padding: 10px 0px 10px 0px; display:block;" />
	</div>
	
	<asp:PlaceHolder ID="VirtualEarthIntegration" runat="server">
	  <div>
	    <asp:hyperlink ID="VirtualEarthLink" runat="server" Text="See where this was taken" Target="_blank" />
	  </div>
	</asp:PlaceHolder>

	<asp:Repeater ID="TagsRepeater" runat="server">
	  <HeaderTemplate>
      <strong>Tags: </strong>
	  </HeaderTemplate>
    <ItemTemplate>
      <a href="#"><asp:Literal ID="TagLabel" runat="server" Text='<%# Eval("Tag.Value") %>'></asp:Literal></a>&nbsp;
    </ItemTemplate>
  </asp:Repeater>
  
  <h3>Ratings</h3>
  
  <asp:PlaceHolder runat="server" ID="downloadRatingBlock" Visible="False">
      <br />
      Downloaded <asp:Literal runat="server" ID="downloadedLabel"/> times - This item 
      has a <asp:Literal runat="Server" ID="downloadRatingLabel" /> star download experience rating.
    </asp:PlaceHolder>
	
	<!-- This is an example of where we have used ASP.NET AJAX to provide some richer user experience by allowing the rating controls to be clicked
	     and asyncronously post back to the server without the user experiencing a postback. We have use the UpdatePanel in combination with the Rating controls
	     from the AJAX toolkit to achieve this -->
	     	
	<asp:UpdatePanel ID="DownloadExperienceRating" runat="server">
    <ContentTemplate>
      <div>Rate the download experience: 
        <ajaxToolkit:Rating ID="DownloadRating" runat="server"
            MaxRating="5"
            StarCssClass="ratingStar"
            WaitingStarCssClass="savedRatingStar"
            FilledStarCssClass="filledRatingStar"
            EmptyStarCssClass="emptyRatingStar"
            OnChanged="DownloadRating_Changed"
           />
      </div><br />
    </ContentTemplate>
  </asp:UpdatePanel>
	
	<asp:UpdatePanel ID="RatingUpdatePanel" runat="server">
    <ContentTemplate>
      <div>Rate this content: 
        <ajaxToolkit:Rating ID="Rating" runat="server"
            MaxRating="5"
            StarCssClass="ratingStar"
            WaitingStarCssClass="savedRatingStar"
            FilledStarCssClass="filledRatingStar"
            EmptyStarCssClass="emptyRatingStar"
            OnChanged="Rating_Changed"
           />
      </div>
    </ContentTemplate>
  </asp:UpdatePanel>
  
  <br />
  <br />
  
  <asp:Panel ID="AdminPanel" runat="Server" Visible="false">
    <h3>Administration</h3>
    <asp:Button ID="DeleteContribution" runat="server" OnClick="DeleteContribution_Click" Text="Delete Contribution" CssClass="button" /> &nbsp; 
    <asp:Button ID="ApproveContribution" runat="server" OnClick="ApproveContribution_Click" Text="Approve Contribution" CssClass="button" />
  </asp:Panel>
  
  <asp:UpdatePanel runat="server" id="CommentsUpdatePanel">
    <ContentTemplate>
    
      <asp:Repeater ID="CommentsRepeater" runat="server">
        <HeaderTemplate>          
          <h3>Comments</h3>
          <br />
        </HeaderTemplate>
        <ItemTemplate>
          <div>
            <asp:Literal runat="server" Text='<%# Eval("Subject") %>'></asp:Literal><br />
            <asp:Literal runat="server" Text='<%# Eval("Message") %>'></asp:Literal><br />
            <asp:Literal runat="server" Text='<%# Eval("Signature") %>'></asp:Literal><br />
          </div>
          <br />
        </ItemTemplate>
      </asp:Repeater>
    
      <h3>Add Comment</h3>
      <br />
      
      <div id="formBox">
      
        <asp:Repeater ID="ErrorsRepeater" runat="server">
          <HeaderTemplate>
            <div class="errors">
          </HeaderTemplate>
          <ItemTemplate>
            <%# Eval("Message") %>
            <br />
          </ItemTemplate>
          <FooterTemplate>
            </div>
          </FooterTemplate>
        </asp:Repeater>
        
        <div class="row">
          <span class="label">Subject:</span>
          <asp:TextBox runat="server" id="SubjectTextBox" Width="400px" />
        </div>
        
        <div class="row">
          <span class="label">Message:</span>
          <asp:TextBox ID="MessageTextBox" runat="server" Columns="50" Rows="5" CssClass="inputTheme" TextMode="MultiLine" Width="400px">
          </asp:TextBox>
        </div>
        
        <div class="row">
          <span class="label">&nbsp;</span>
          <asp:Button runat="server" id="AddCommentButton" Text="Add Comment" OnClick="AddCommentButton_Click" />
        </div>
      </div>
      
    </ContentTemplate>
    
  </asp:UpdatePanel>  
 
</asp:Content>
